package cn.lcsjsxy.yxz.day.Set;

import java.util.ArrayList;

//泛型1
public class fanxing1 {

    public static void main(String[] args) {

        ArrayList list = new ArrayList();

//        User1 user = new User1();
//        user.testUser();

//        Person1 user = new Person1();
//        user.testUser();
//        user.testPerson();

        Person1 person = new Person1();
        User1 user = new User1();

        list.add(person);
        list.add(user);

        //获取的对象类型为Object
        Object o = list.get(0);
        //转换
        if (o instanceof Person1){
            Person1 p = (Person1) o;
            p.testPerson();
        }

    }

}

class Person1 {
    public void testPerson() {
        System.out.println("Person test method");
    }
}
class User1 {
    public void testUser() {
        System.out.println("User test method");
    }
}